<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@taglib uri="estateTag" prefix="estateTag" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title>商家信息</title>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<link rel="stylesheet" href="../resource/css/global.css"
			type="text/css"></link>
		<link rel="stylesheet" type="text/css"
			href="../resource/css/easyui/default/easyui.css">
		<link rel="stylesheet" type="text/css"
			href="../resource/css/easyui/icon.css">
		<script type="text/javascript" src="../resource/js/jquery-1.4.2.js"></script>
		<script src="../resource/js/jquery.tip.js"></script>
		<script type="text/javascript"
			src="../resource/js/easyui/jquery.easyui.min.js"></script>
		<script type="text/javascript"
			src="../resource/js/easyui/easyui-lang-zh_CN.js"></script>
		<link rel="stylesheet" type="text/css"
			href="../resource/js/kindeditor/skins/default.css"></link>
		<script type="text/javascript"
			src="../resource/js/kindeditor/kindeditor.js"></script>
		<link rel="stylesheet" href="../resource/css/whole.css"
			type="text/css"></link>
		<link rel="stylesheet" href="../resource/css/global.css"
			type="text/css"></link>
		<link rel="stylesheet" href="../resource/css/memberCenter/infowithoutmenu.css"
			type="text/css"></link>
	</head>
	<script type="text/javascript">
  String.prototype.getBytes = function() {
	var cArr = this.match(/[^\x00-\xff]/ig);
	return this.length + (cArr == null ? 0 : cArr.length);
}
    var  a=0;
    function checkImage(obj) {
	if (/(.gif)|(.png)|(.jpg)|(.jpeg)|(.ico)$/.exec(obj.value))
		return true;
	else
		return false;
  }
// 为true不等于空
function checkNull(obj) {
	if (obj.value.trim().length == 0)
		return false;
	else
		return true;
 }

function  checkSave(){
 var  name= $("#name").val();
 if(""==name){
    alert("请填写品牌名");
    $("#name").focus();
    return false;
 }
var  brandid=document.getElementById("brandid").value;
if(brandid==""){
      	var  img=document.getElementById("imglog");
       	if (img.value!=undefined) {
		     if (!checkImage(img)) {
		       alert('品牌log图片上传格式不正确，应为 gif、png、jpg、jpeg、ico格式');
		     img.focus();
		    return false;
		      }
		}
		var  imgpic=document.getElementById("imgpic");
     	if (imgpic.value!=undefined) {
			  if (!checkImage(imgpic)) {
			  	alert('商家图片上传格式不正确，应为 gif、png、jpg、jpeg、ico格式');
			  	imgpic.focus();
			 	return false;
			}
  		}
}
   var  username= $("#username").val();
   var oldUsername = $('#oldusername').val();
   if(""== username){
       alert("请填写商家登入名");
       $("#username").focus();
       return  false;
   }else{
   if(username != oldUsername && oldUsername != ""){
      	var usernameLength = username.getBytes();
		var partern = /^[(\u4e00-\u9fa5)(a-z)(A-Z)(0-9)(_)]+$/i;
		if (!partern.test(username)) {
			alert('用户名不合法，只能为汉字，数字，字母，下划线');
			return;
		}
	
		if (usernameLength < 6 || usernameLength > 18) {
			alert('用户名为6到18位');
			return;
		}
		$.ajax({
			url :'../user/checkUserName.shtml?username='
					+ encodeURI(username),
			method : "get",
			cache : false,
			success : function(message) {
				if (message == "2") {
					alert('用户名已经被注册了');
					return;
				} else if (message == "3") {
					alert('服务器出现异常，请稍后再试');
					return;
				} else if (message == "1") {
					var  password= $("#password").val();
				    if(""== password){
				       alert("请填写商家登入密码");
				       $("#password").focus();
				       return false;
				    }else{
				    	var usernameLength = password.getBytes();
						if (usernameLength < 6 || usernameLength > 18) {
							alert('密码为6到18位');
							$('#password').focus();
							return false;
						}
				    }
				 //   $("#brandDescValue").val(KE.util.getData('content1'));
				    var  statement= $("#statement").val();
					 if(""==statement){
					    alert("请填写商家声明");
					    $("#statement").focus();
					    return false;
					 }
					  if($("#statement").val().length>200)
					 {  
					      alert("商家声明输入已超过200个字");
	                     $("#statement").focus();
	                     return false;
					 }
				    document.forms[0].submit();
				}
			}
		});
		}else{
			var  password= $("#password").val();
			if(""== password){
		       alert("请填写商家登入密码");
		       $("#password").focus();
		       return false;
		    }else{
		    	var usernameLength = password.getBytes();
				if (usernameLength < 6 || usernameLength > 18) {
					alert('密码为6到18位');
					$('#password').focus();
					return false;
				}
		    }
		  //  $("#brandDescValue").val(KE.util.getData('content1'));
		    var  statement= $("#statement").val();
					 if(""==statement){
					    alert("请填写商家声明");
					    $("#statement").focus();
					    return false;
					 }
			  if($("#statement").val().length>200)
					 {  
					      alert("商家声明输入已超过200个字");
	                     $("#statement").focus();
	                     return false;
					 }
		    document.forms[0].submit();
		}
   }
}  
    
var a = 0;
var checkUsername = false;
function checkloginuserName(username) {
	checkUsername = false;
	a = 0;
	var usernameLength = username.getBytes();
	var partern = /^[(\u4e00-\u9fa5)(a-z)(A-Z)(0-9)(_)]+$/i;
	if (!partern.test(username)) {
		a = 1;
		$("#successMes").hide();
		$("#errorMes").show();
		$("#errorMes").focus();
		$("#errorMes").html('用户名不合法，只能为汉字，数字，字母，下划线');
		return;
	}

	if (usernameLength < 6 || usernameLength > 18) {
		a = 1;
		$("#successMes").hide();
		$("#errorMes").show();
		$("#errorMes").focus();
		$("#errorMes").html('用户名为6到18位');
		return;
	}
	$("#errorMes").hide();
	$.ajax({
		url :'../user/checkUserName.shtml?username='
				+ encodeURI(username),
		method : "get",
		cache : false,
		success : function(message) {
			checkUsername = true;
			if (message == "2") {
				a = 1;
				alert('用户名已经被注册了');
				return;
			} else if (message == "3") {
				a = 2;
				alert('服务器出现异常，请稍后再试');
				return;
			} else if (message == "1") {
				a = 0;
			}
		}
	});
}
    
   function checkloginuserName(username){
	            $.get("../user/checkUserName.shtml?user.username="+username,function(message){
					if(message == "2"){
						alert("用户名已经被注册了");
						  a=1;
				
					}else if(message == "3") {
						alert("服务器出现异常，请稍后再试");
						a=1;
					}else {
					  a=0;
					}
					
				})
	   }
	   
	    function checkloginReuserName(username,oldusername){
	            $.get("../user/modifycheckUserName.shtml?user.username="+username+"&oldusername="+oldusername,function(message){
					if(message == "2"){
						alert("用户名已经被注册了");
						  a=1;
				
					}else if(message == "3") {
						alert("服务器出现异常，请稍后再试");
						a=1;
					}else {
					  a=0;
					}
					
				})
	   }
	   $(function(){
	   	$("#username").tip({height:'25px',width:'420px','font-size':'13px','line-height':'25px','padding-left':'5px'},"<font style='color:black'>6-18个字符，可使用字母、数字、下划线、中文，一个汉字为2个字符</font>","2");
		$("#password").tip({height:'25px',width:'220px','font-size':'13px','line-height':'25px','padding-left':'5px'},"<font style='color:black'>6-18个字符，不允许使用汉字</font>","2")
	   })
  </script>
	<body><estateTag:security></estateTag:security>
		<center><jsp:include page="../index/top.jsp"></jsp:include></center>
		<div style="width: 100%; margin-top: 10px;" align="center">
			<input id="menuCls" type="hidden" value="331">
			<table width="100%" class="layoutTab">
				<tr>
				<!-- 	<td width="20%" align="left" valign="top"><jsp:include
							page="../menu.jsp"></jsp:include></td> -->
					<td valign="top" align="center">
						<form name="form" method="post"
							action="../brand/addSaveOrUpdate.shtml"
							enctype="multipart/form-data">
							<div class="position" align="left">
								<label>
									您所在的位置：
								</label>
								拼购管理模块&nbsp;&nbsp;--&gt;&gt;&nbsp;&nbsp;商家管理&nbsp;&nbsp;--&gt;&gt;&nbsp;&nbsp;商家信息维护
							</div><br/>
							<div class="info_top"></div>
							<div class="info_mid" align="center">
								<table width="100%" border="0" cellpadding="1" cellspacing="1">
									<tr>
										<td align="center" colspan="2">
											<b>商家信息编辑 （<font color="red">*</font> 为必填项）</b>
										</td>
									</tr>
									<tr>
										<td align="right" width="16%">
											<font color="red">*</font>品牌：
										</td>
										<td align="left">
											<input type="text" maxlength="50" id="name"
												name="tgBrand.name" value="${tgBrand.name}">
										</td>
									</tr>
							<!-- 	<tr>
										<td align="right" width="16%">
											简介标题：
										</td>
										<td align="left">
											<input type="text" maxlength="50" id="accTitle" style="width: 250px"
												name="tgBrand.accTitle" value="${tgBrand.accTitle}">
										</td>
									</tr> -->	
									<tr>
										<td align="right">
											<font color="red">*</font> 品牌log：
										</td>
										<td align="left">

											<s:if test="#request.tgBrand.imgsrc!= null">
												<img src="../${tgBrand.imgsrc}" height="45px" width="144px" />
												<br />
												<input type="file" id="imglog" name="imglog" />
											</s:if>
											<s:else>
												<input type="file" id="imglog" name="imglog" />
											</s:else>
<font color="red" >（建议图片大小宽144px,高45px）</font>
										</td>
									</tr>
									<tr>
										<td align="right">
											<font color="red">*</font> 商家图片：
										</td>
										<td align="left">
											<s:if test="#request.tgBrand.brandPic!= null">
												<img src="../${tgBrand.brandPic}"  width="500px" height="140px" />
												<br />
												<input type="file" id="imgpic" name="imgpic" />
											</s:if>
											<s:else>
												<input type="file" name="imgpic" id="imgpic" />
											</s:else>
									<font color="red" >（建议图片大小宽1000px,高280px）</font>
										</td>
									</tr>
									<tr>
										<td align="right" width="16%">
											<font color="red">*</font>商家登入名：
										</td>
										<td align="left">
											<s:if test="#request.user.username!= null">
												<input type="text" maxlength="20" name="user.username"
													id="username" value="${user.username}">
											</s:if>
											<s:else>
												<input type="text" maxlength="20" name="user.username"
													id="username" value="${user.username}">
											</s:else>
											<input type="hidden" id="oldusername"
													value="${user.username}">
											<input type="hidden" maxlength="20" id="type"
												name="user.type" value="2">
										</td>
									</tr>
									<tr>
										<td align="right" width="16%">
											<font color="red">*</font>商家密码：
										</td>
										<s:if test="#request.user.password!= null">
											<td align="left">

												<input type="text" maxlength="20" id="password"
													name="user.password" value="${user.password}">
											</td>
										</s:if>
										<s:else>
											<td align="left">
												<input type="text" maxlength="20" id="password"
													name="user.password" value="000000">
											</td>
										</s:else>

									</tr>

									<tr>
										<td align="right">

										</td>
										<td align="left">
										</td>
									</tr>
                                     <tr>
												<td align="right">
												<font color="red">*</font>		商家声明：
												</td>
												<td align="left">
														<textarea cols="60" rows="10"  id="statement" name="tgBrand.stateMent">${tgBrand.stateMent}</textarea>
												</td>
											</tr>   
									<tr>
										<td colspan="2" align="center">
											<input type="hidden" name="tgBrand.auding"
												value="${tgBrand.auding}">
											<input type="hidden" name="tgBrand.id" id="brandid"
												value="${tgBrand.id}">
											<input type="hidden" name="user.id" value="${user.id}">
											<!-- 审核状态 未审核 -->

											<input type="button" onclick="checkSave()" value="保存">
											&nbsp;
											<input type="button" value="返回" onclick="goback()">
										</td>
									</tr>
								</table>
							</div>
							<div class="info_bottom">
								&nbsp;
							</div>
						</form>
					</td>
				</tr>
			</table>
		</div>
		<input type="hidden" />
		<div style="margin-top: 10px;">
		</div>
		<center> <iframe src="../index/footer.html" width="970" height="120" frameborder="0" scrolling="no"></iframe> </center></body>
	<script>
	/*	KE.show({
				id : 'content1',
				loadStyleMode : false,
				resizeMode : 0,
				allowUpload:true, //允许上传图片 
				imageUploadJson:'<%=basePath%>/comutil/upload.shtml',    
				items : [
				'fontname', 'fontsize', '|', 'textcolor', 'bgcolor', 'bold', 'italic', 'underline',
				'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
				'insertunorderedlist', '|','image', '|','fullscreen']
			});*/
		  function goback()
          {
            history.back();
          }
		</script>
</html>
